package acceptance;

import junit.framework.Assert ;
import presentation.UIPost ;
import presentation.UIThread ;


/**
 * @author reut
 * tests different parameters of adding posts
 * IMPORTANT:in order to work these conditions need to hold:
 *  not exist: threadId:1400
 *  exist: threadId:1,writerId:1
 */
public class AddPostTest extends ProjectTest
{
	@Override
	public void setUp(){
		super.setUp();
		this._bridge.register("dani", "1234");
		this._bridge.login("dani", "1234");
	}

	/**
	 * tests cases of successful adding posts
	 */
	public void testCorrectAddPost()
	{

		//Assert.assertTrue("added post succssesfuly", this._bridge.addPost(1, "hello this is a test",1));
		UIThread t = this._bridge.createNewThread("topic1", 2) ;
		Assert.assertNotNull(t) ;
		UIPost p = this._bridge.addPost(t.getId(),"hello this is a test",2) ;
		Assert.assertNotNull(p) ;
		Assert.assertEquals("added post succssesfuly",2,p.getWriterId());


	}

	/**
	 *  tests when threadId or writerId doesn't exist in the system
	 */
	public void testUnpermittedActionAddPost()
	{

		Assert.assertEquals("writerId or threadId not found-meaning if not registered can't add posts",null,this._bridge.addPost(-1,"hello",2)) ;
		//Assert.assertFalse("writerId or threadId not found-meaning if not registered can't add posts", this._bridge.addPost(this._bridge.createNewThread(-1, "topic1"),"hello",1));
	}

}
